package cn.iocoder.yudao.module.hs.dal.mysql.entryorderdetail;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.hs.controller.admin.entryorderdetail.vo.EntryOrderDetailPageReqVO;
import cn.iocoder.yudao.module.hs.controller.admin.entryorderdetail.vo.EntryOrderDetailRespVO;
import cn.iocoder.yudao.module.hs.dal.dataobject.entryorderdetail.EntryOrderDetailDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 入库单明细 Mapper
 *
 * @author 航盛
 */
@Mapper
public interface EntryOrderDetailMapper extends BaseMapperX<EntryOrderDetailDO> {

    default PageResult<EntryOrderDetailDO> selectPage(EntryOrderDetailPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<EntryOrderDetailDO>()
                .eqIfPresent(EntryOrderDetailDO::getOrderId, reqVO.getOrderId())
                .likeIfPresent(EntryOrderDetailDO::getMaterialName, reqVO.getMaterialName())
                .likeIfPresent(EntryOrderDetailDO::getMaterialCode, reqVO.getMaterialCode())
                .likeIfPresent(EntryOrderDetailDO::getModeCode, reqVO.getModeCode())
                .likeIfPresent(EntryOrderDetailDO::getBoxCode, reqVO.getBoxCode())
                .likeIfPresent(EntryOrderDetailDO::getTrayCode, reqVO.getTrayCode())
                .eqIfPresent(EntryOrderDetailDO::getWarehouseId, reqVO.getWarehouseId())
                .betweenIfPresent(EntryOrderDetailDO::getEntryTime, reqVO.getEntryTime())
                .betweenIfPresent(EntryOrderDetailDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(EntryOrderDetailDO::getId));
    }

    default List<EntryOrderDetailDO> selectListByShipOrderId(Long shipOrderId) {
        return selectList(EntryOrderDetailDO::getShipOrderId, shipOrderId);
    }

    @DataPermission(enable = false)
    IPage<EntryOrderDetailRespVO> selectPageNotEntryRecord(IPage<EntryOrderDetailRespVO> ipage, @Param("pageReqVO") EntryOrderDetailPageReqVO pageReqVO);
}